<?php

use console\db\channels\TransferTableMigration;
use yii\db\Query;

/**
 * 球迷学院答案迁移
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m300060_000005_t_college_answer extends TransferTableMigration {

    /**
     * @inheritdoc
     */
    public $sourceDb = 'olddb';

    /**
     * @inheritdoc
     */
    public function getTransferOptions() {
        return [
            'table' => [
                'college_answer' => 'a_answer',
            ],
            'columns' => [
                'id',
                'question_id',
                'content',
                'char',
                'right',
                'choose_count',
                'status' => function($data) {
                    if ($data['status']) {
                        return 10;
                    }
                    return 0;
                },
                'created_at' => function($data) {
                    if ($data['created_at']) {
                        return $data['created_at'];
                    }
                    return strtotime('-1 year');
                },
                'updated_at' => function($data) {
                    if ($data['updated_at']) {
                        return $data['updated_at'];
                    }
                    return time();
                },
                'deleted_at',
            ],
        ];
    }

}
